<script>
  var res = '1234'.match(/(\d)(\d)(\d)(\d)/);
  console.log(res);
</script>

<script>
  var str = 'Regular Capture';
  var reg = /(\w+)\s(\w+)/gi;
  var newstr = str.replace(reg, '$2 $1');
  console.log(newstr);    // 输出结果为：Capture Regular
</script>

<script>
  // ① 非捕获
  var reg = /(?:J)(?:S)/;
  var res = 'JS'.replace(reg,'$2 $1');
  console.log(res);    // 输出结果：$2 $1

  // ② 捕获
  var reg = /(J)(S)/;
  var res = 'JS'.replace(reg,'$2 $1');
  console.log(res);    // 输出结果：S J
</script>

<script>
  var str = '13335 12345 56668';
  var reg = /(\d)\1\1/gi;
  var match = str.match(reg);
  console.log(match);    // 输出结果为：(2) ["333", "666"]
</script>
<p>
  <a href="file:///C:/Users/rise/Desktop/%E9%A6%96%E9%A1%B5/default/09.html">返回</a>
</p>